#ifndef RENDERER_H
#define RENDERER_H

#include "core/Component.h"
#include "core/GameObject.h"
#include "types/Color.h"
#include <SDL/SDL.h>

namespace SolidityEngine
{



class Renderer : public Component
{
    public:
        enum RenderTarget {
            RT_SCREEN,
            RT_SCENE
        };


        Renderer(RenderTarget target = RT_SCENE);
        virtual ~Renderer();

        Color32& Color() {return _color;};
        Color32 Color() const {return _color;};

        void Render(SDL_Surface* surface){if(_enabled) _Render(surface);};

        //The Index of a renderer defines the draw order.
        int& Index(){return _index;};
        int Index() const {return _index;};

        static bool Compare(Renderer* first, Renderer* second){
            return (first->Index()<second->Index());
        }

        RenderTarget GetRenderTarget() const {return _target;};
        void SetRenderTarget(RenderTarget target){_target=target;};

    protected:
        Color32 _color;
        int _index;
        void SetPixel32(SDL_Surface *surface, int x, int y, Uint32 pixel);
        RenderTarget _target;

    private:
        virtual void _Render(SDL_Surface* surface);
};

};
#endif // RENDERER_H
